package com.opgea.token.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.opgea.token.service.CompanyService;
import com.opgea.token.web.dto.CompanyDTO;

public class InitializeApp {

    @Autowired
    private CompanyService companyService;

    public Object callBean(String beanName) {
	ApplicationContext context = new ClassPathXmlApplicationContext(
		"WebContent/WEB-INF/applicationContext.xml");
	return context.getBean(beanName);
    }

    public void createCompany() {
	companyService = (CompanyService) callBean("companyService");
	CompanyDTO dto = new CompanyDTO();
	dto.setName("OPGEA Systems");
	dto.setWebsite("www.opgea.com");
	dto.setEmail("shekhar@gmail.com");
	companyService.create(dto);
    }

    public static void main(String args[]) {
	InitializeApp app = new InitializeApp();
	app.createCompany();
    }
}
